#!/usr/bin/env python

import sys
import code
import readline
import rlcompleter
readline.parse_and_bind("tab: complete")

from rflib import *



intro = """

Don't you wish this were a CLI!?  Sorry.  Maybe soon...
For now, enjoy the raw power of rflib, or write your own device-specific CLI!

currently your environment has an object called "d" for dongle.  this is how 
you interact with the rfcat dongle, for :
    >>> d.ping()
    >>> d.setFreq(433000000)
    >>> d.setMdmModulation(MOD_ASK_OOK)
    >>> d.makePktFLEN(250)
    >>> d.RFxmit("HALLO")
    >>> d.RFrecv()
    >>> print d.reprRadioConfig()

"""

if __name__ == "__main__":
    idx = 0
    if len(sys.argv) > 1:
        idx = int(sys.argv.pop())
    d = FHSSNIC(idx=idx)

gbls = globals()
lcls = locals()

try:
    import IPython.Shell
    ipsh = IPython.Shell.IPShell(argv=sys.argv, user_ns=lcls, user_global_ns=gbls)
    ipsh.mainloop(intro)
except ImportError, e:
    shell = code.InteractiveConsole(lcls)
    shell.interact(intro)

